package com.ss.tmall.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ss.tmall.pojo.User;
import com.ss.tmall.service.UserService;
import com.ss.tmall.util.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

/**
 * @Author: ShengShuai
 * @Description:
 * @Date: Created in 下午 21:35  2017/12/27 0027
 * @Modified By:
 */
@Controller
@RequestMapping("")
public class UserController {
    @Autowired
    UserService userService;
    @RequestMapping("admin_user_list")
    public  String list(Model model, Page page){
        PageHelper.offsetPage(page.getStart(),page.getCount());
        List<User> users = userService.list();
        int total= (int)new PageInfo<>(users).getTotal();
        page.setTotal(total);
        model.addAttribute("us" ,users);
        model.addAttribute("page",page);
        return  "admin/listUser";
    }

}
